package com.moneylee.xdstudy.utils;

/**
 * @className: JsonData
 * @Description: 返回结果包装
 * @Author moneylee
 * @Date 2020-06-30 17:13
 * @Version 1.0
 **/
public class JsonData {

    private int code;
    private Object data;
    private String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "JsonData{" +
                "code=" + code +
                ", data=" + data +
                ", msg='" + msg + '\'' +
                '}';
    }

    public JsonData(){}

    public JsonData(int code, Object data, String msg){
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public JsonData(int code, Object data) {
        this.code = code;
        this.data = data;
    }

    public JsonData(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static JsonData buildSuccess(Object data) {
        return new JsonData(0, data, "请求成功！");
    }

    public static JsonData buildError(String msg) {
        return new JsonData(-1, msg);
    }

    public static JsonData budileError(int code, String msg) {
        return new JsonData(code, msg);
    }

}
